package com.glela.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.glela.goods.service.CategoryService;
import com.glela.platform.constant.ErrorEnum;
import com.glela.platform.model.response.ResponseBaseModel;
import com.glela.platform.model.response.ResponseResultModel;

@Controller
@RequestMapping("category")
public class CategoryController {


	private static Logger logger = LoggerFactory.getLogger(CategoryController.class);

	@Autowired
	private CategoryService categoryService;
	
	/**
	 * 查询分类
	 * @return
	 */
	@RequestMapping(value = "/listCategory", method = RequestMethod.POST, consumes = "application/json")
	public ResponseEntity<?> listCategory() {
		try {
			return new ResponseEntity<>(
					new ResponseResultModel<>(categoryService.listCategory()),
					HttpStatus.OK);
		} catch (Exception e) {
			logger.error("查询分类列表异常", e);
			return new ResponseEntity<>(new ResponseBaseModel(ErrorEnum.C20000), HttpStatus.OK);
		}
	}


}
